Code lijnen

3.2s

terug

/*regular multilateral with diagonals from Lauwerier graphics&Fractals Schoonhoven, 1994
chapter 3.2 translated by J.G.van Unnik*/
//name:LACE
size(400,400);
translate(200,200);
background(255);
stroke(0);
smooth();
int N=17,zoom=198;
float x[]=new float[N];
float y[]=new float[N];
for(int k=0;k<N;k++){
x[k]=zoom*cos(2*k*PI/N);
y[k]=zoom*sin(2*k*PI/N);
}
for(int i=0;i<N;i++){
for(int j=0;j<i;j++){
line(x[i],y[i],x[j],y[j]);
}
}

3.3s

terug

/*multiple rotating lines from Lauwerier graphics&Fractals Schoonhoven, 1994
chapter 3.3 translated by J.G.van Unnik*/
//name:TURNLINE
// Shift the origin (0,0) to the center and resize window(2,1.5)
size(400, 300);
background(255);
translate(width/2,height/2);
scale(100);  //corresponds to BASIC window(-2,-1.5)-(2,1.5)
strokeWeight(.01);
stroke(0,100);
smooth();

float a=.4,b=6,r=.6,n=256;
for(int k=0;k<4;k++){
for(int l=0;l<n;l+=1){
float RK=pow(r,k),T1=2*l*PI/n,T2=b*l*PI/n;
float X0=RK*cos(T1),Y0=RK*sin(T1);
float X1=a*RK*cos(T2),Y1=a*RK*sin(T2);
line(X0-X1,Y0-Y1,X0+X1,Y0+Y1);
}
}

3.4s

terug

/*regular multilateral with diagonals from Lauwerier graphics&Fractals Schoonhoven, 1994
chapter 3.1 translated by J.G.van Unnik*/
//name:LACE
int N=33,P=11,Q=15,zoom=200,cycle=0;
float x[]=new float[50];
float y[]=new float[50];

void setup(){
size(400,400);
background(255);
stroke(0);
smooth();
noLoop();
}
void draw(){
translate(200,200);
for(int k=0;k<N;k++){
x[k]=zoom*cos(2*k*PI/N);
y[k]=zoom*sin(2*k*PI/N);
}
for(int i=P;i<Q;i++){
for(int j=0;j<N;j++){
int k=(i+j)%N;
line(x[j],y[j],x[k],y[k]);
}
}
}

void mousePressed(){
cycle=cycle+1;

switch(cycle) {
case 1:
N=25;P=7;Q=10;
break;
case 2:
N=25;P=7;Q=15;
break;
case 3:
N=25;P=9;Q=10;
break;
case 4:
N=25;P=12;Q=15;
break;
case 5:
N=45;P=17;Q=20;
break;
case 6:
N=35;P=10;Q=16;
break;
default:
N=33;P=11;Q=15;cycle=0;
break;
}
background(255);
redraw();
}

3.5s

terug

/*astroid from Lauwerier graphics&Fractals Schoonhoven, 1994
chapter 3.1 translated by J.G.van Unnik*/
//name astroid
int N=64,zoom=140,cycle=0;
void setup(){
size(300,300);
background(255);
stroke(0);
noLoop();
}
void draw(){
translate(width/2,height/2);
for(int I=0;I<N;I++){
float T=2*PI*I/N;
line(zoom*cos(T),0,0,zoom*sin(T));
}
}
void mousePressed(){
int cmax=4,n=32;
cycle=cycle+1;
if(cycle>cmax){cycle=1;}
N=cycle*n;
background(255);
redraw();
}

3.7s

terug

//ch.3.2 cyclo2
/*from H.A.Lauwerier Spelen met graphics en Fractals Schoonhoven, 1994 ISBN 90-395-0092-4 with 80 programs in QBasic and PowerBasic
translated into Processing by J.G.van Unnik, 2010*/
float A=1,K=1,L=2,zoom=200,N=100,EPS=.001;
float U[]=new float[2];
float V[]=new float[2];
int cycle=0;
void setup(){ 
size(400,400);
background(255);
stroke(0);
//smooth();
noLoop();
}
void draw(){
translate(width/2,height/2);
for (float J=0;J<N+1;J++){
float T=2*PI*L*J/N;
float A1,B1,A2,B2;
A1=cos(T);B1=sin(T);A2=cos(K*T/L);B2=sin(K*T/L+EPS);
float P=B1-B2,Q=A1-A2,R=(A1*B2-A2*B1)*A;
int S=0;
if (abs(Q-R)<=abs(P)){U[S]=(Q-R)/P;V[S]=-1;S=S+1;}
if (abs(Q+R)<=abs(P)){U[S]=-(Q+R)/P;V[S]=1;S=S+1;}
if (abs(P-R)<abs(Q)){V[S]=(P-R)/Q;U[S]=-1;S=S+1;}
if (abs(P+R)<abs(Q)){V[S]=-(P+R)/Q;U[S]=1;S=S+1;}
line(zoom*U[0],zoom*V[0],zoom*U[1],zoom*V[1]);
}
}
void mousePressed(){
int cmax=2;
cycle=cycle+1;
if(cycle>cmax){cycle=0;}
switch(cycle){
case 1:
K=-1;L=2;A=.25;
break;
case 2:
K=1;L=3;A=.8;
break;
default:
K=1;L=2;A=1;
break;

background(255);
redraw();

3.8s

terug

/*vortex variant
adapted from H.A.Lauwerier Spelen met graphics en Fractals Schoonhoven, 1994 ISBN 90-395-0092-4 with 80 programs in QBasic and PowerBasic
translated into Processing by J.G.van Unnik, 2010*/
int P=4;  //number of sides
float B=.1;  //angle of rotation
float scaleFactor=100;       //corresponds to window (-1,-1)-(1,1)

void setup(){
size(200,200);
background(255);
stroke(0);
smooth(); 
noLoop();
}
void draw(){
translate(width/2,height/2);
float[]X=new float[P+1];
float[]Y=new float[P+1];
float A=PI*(1.0-2.0/P),C=sin(A)/(sin(B)+sin(A+B));
for(int k=0;k<P+1;k++){
float T=(2*k+1.0)*PI/P;
X[k]=sin(T);
Y[k]=cos(T);
}
for(int n=1;n<40;n++){
for(int l=1;l<P+1;l++){
int X0=int(scaleFactor*X[l-1]),Y0=int(scaleFactor*Y[l-1]),X1=int(scaleFactor*X[l]),Y1=int(scaleFactor*Y[l]);
stroke(0,255-n*6);    //the second term makes smaller figures fade into the background
line(X0,Y0,X1,Y1);
}
for(int m=0;m<P+1;m++){
float Z=X[m];
X[m]=(X[m]*cos(B)-Y[m]*sin(B))*C;
Y[m]=(Z*sin(B)+Y[m]*cos(B))*C;
}
}
}
void mousePressed(){
int Pmax=9;
P=P+1;
if(P>Pmax){P=3;} 
background(255);
redraw();
}

terug